money = 5000000
name = None
name = input("请输入您的姓名：")
def query_money(show_header):
    global money
    if show_header:
        print("______________________________查询余额______________________________")
    print(f"{name}，你好，你的余额剩余为：{money}元。")

def save_money():
    global money
    num = int(input("请输入存款："))
    money += num
    print("______________________________存款______________________________")
    print(f"{name}，你好，你存款：{num}元成功。")
    query_money(False)

def get_money():
    global money
    num = int(input("请输入取款："))
    money -= num

    print("______________________________取款______________________________")
    print(f"{name}，你好，你取款：{num}元成功。")
    query_money(False)



def main_ideal():
    print(f"______________________________主菜单______________________________")
    print(f"{name},你好，请选择操作：")
    print("查询余额：\t[[输入1]")
    print("存款：\t\t[[输入2]")
    print("取款：\t\t[[输入3]")
    print("退出：\t\t[[输入4]")
    return int(input("请输入您的选择："))

count = 0
max_attempts = 5  # 最大尝试次数
verified = False
while count < max_attempts:
    code = int(input("请输入密码："))
    if code == 434445:
        print("密码正确！")
        verified = True
        # main_ideal()  # 假设这是正确后的函数
        break
    else:
        count += 1  # 先计数，再计算剩余次数
        remaining = max_attempts - count
        if remaining > 0:
            print(f"密码错误，您还有{remaining}次机会。")
        else:
            print("密码错误，已超过最大尝试次数！")

if verified:
    # main_ideal()
    while True:
        keyword_input = main_ideal()
        if keyword_input == 1:
            query_money(True)
            continue
        elif keyword_input == 2:
            save_money()
            continue
        elif keyword_input == 3:
            get_money()
            continue
        else:
            break